<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    table{border-collapse:collapse; width:400px}
    th,td{border:1px solid #555; text-align:center}
  </style>
</head>
<body>
  <table>
    <thead>
      <tr>
        <th>编号</th>
        <th>姓名</th>
        <th>薪资</th>
        <th>年龄</th>
      </tr>
    </thead>
    <tbody id="tbody">
      <!--<tr>
        <td>1001</td>
        <td>eric</td>
        <td>12000</td>
        <td>25</td>
      </tr>-->
    </tbody>
  </table>
  <script>
    var emps=[
      {id:1001,ename:"eric",salary:12000,age:25},
      {id:1002,ename:"jack",salary:15000,age:28},
      {id:1003,ename:"rose",salary:11000,age:21}
    ];
    var html="";
    //for(var i=0;i<emps.length;i++){
      //var {id,ename,salary,age}=emps[i];
    //for(var emp of emps){
      //var {id,ename,salary,age}=emp;
    for(var {id,ename,salary,age} of emps){
      html+=`<tr>
        <td>${id}</td>
        <td>${ename}</td>
        <td>${salary}</td>
        <td>${age}</td>
      </tr>`;
    }
    document.getElementById("tbody").innerHTML=html;
  </script>
</body>
</html>